package spring.bean;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 多例bean
 */
@Scope("prototype")
@Component
public class PrototypeBean {

    @PostConstruct
    public void init() {
        System.out.println("prototype bean init");
    }

    @PreDestroy //单例在spring容器销毁时执行destroy方法，prototype则不会
    public void destroy() {
        System.out.println("prototype bean destroy");
    }
}
